{extend name='admin@main'}

{block name="content"}
<form class="layui-form layui-card" onsubmit="return false;"  action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label label-required">文章分类</label>
            <div class="layui-input-block label-required">
            <select class="layui-input-block label-required" name="cate_id" lay-search>
                {foreach $cateData as $cate}
                {if isset($vo.cate_id) and $vo.cate_id eq $cate.id}
                <option selected value="{$cate.id}">{$cate.name|default=''}</option>
                {else}
                <option value="{$cate.id}">{$cate.name|default=''}</option>
                {/if}
                {/foreach}
            </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章标题</label>
            <div class="layui-input-block label-required">
                <input name="name" value='{$vo.name|default=""}' required placeholder="请输入文章标题" class="layui-input">
                <!--{/if}-->
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <input name="desc" value='{$vo.desc|default=""}'  placeholder="请输入描述" class="layui-input">
                <!--{/if}-->
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label label-required">封面图片</label>
            <div class="layui-input-block">
                <input name="pic" type="hidden" value="{$vo.pic|default=''}">
                <!--{/if}-->
            </div>
            <script>$('[name="pic"]').uploadOneImage()</script>
        </div>
        <div class="layui-form-item">
            <h3 class="color-green"><sup class='color-red font-s14 absolute' style="margin-left:-10px">*</sup>商品内容</h3>
            <textarea name="content">{$vo.content|default=''|raw}</textarea>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>

{/block}
{block name='script'}
    <script>
        window.form.render();
        require(['ckeditor', 'angular'], function () {
            window.createEditor('[name="content"]', {height: 500});
            }
        );
    </script>
{/block}